package com.hdd.art.filter.filter;

import com.hdd.art.filter.filter.impl.ApiHandlerInterceptor;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


/**
 * 
* @ClassName: CustomWebMvcConfigurer 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author 刘章 
* @date 2020年10月12日 下午1:58:49 
*
 */
@Component
public class CustomWebMvcConfigurer
        implements
        WebMvcConfigurer
{
	@Resource
	private ApiHandlerInterceptor apiHandlerInterceptor;
	
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		//注册多个Interceptor  注意路径的写法
		registry.addInterceptor(apiHandlerInterceptor).excludePathPatterns("/tool/**","/swagger-ui.html","/webjars/**","/swagger-resources/**","/v2/**","/templates/**","/static/**","*.html");
		//注册某个拦截器的时候，同时排除某些不拦截的路径
		//registry.addInterceptor(new TwoIntercepter()).addPathPatterns("/api2/*/**").excludePathPatterns("/api2/xxx/**");
		WebMvcConfigurer.super.addInterceptors(registry);
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		//第一个方法设置访问路径前缀，第二个方法设置资源路径
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
		registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
	}
}
